package com.qfhd.soft.cjzcore.UI.MulitRecycle.viewholder;

import android.annotation.SuppressLint;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.qfhd.soft.cjzcore.Core.CJCore;
import com.qfhd.soft.cjzcore.UI.Core.DecimalFormatHelper;
import com.qfhd.soft.cjzcore.UI.MulitRecycle.bean.Task_image_Bean;
import com.qfhd.soft.cjzcore.R;
import com.qmuiteam.qmui.widget.QMUIRadiusImageView;

public class Task_image_ViewHolder extends BaseViewHolder {

    //    @BindView(R.id.image_task_icon)
    private QMUIRadiusImageView icon;
    //    @BindView(R.id.image_task_title)
    private TextView tx_title;
    //    @BindView(R.id.image_task_subTitle)
    private TextView tx_subtitle;
    //    @BindView(R.id.image_task_money)
    private TextView tx_money;
    //    @BindView(R.id.image_task_count)
    private TextView tx_count;
    //    @BindView(R.id.image_task_subIcon)
    private ImageView img_sub;

    //    @BindView(R.id.image_status_layout)
    private RelativeLayout status_layout;
    //    @BindView(R.id.image_status)
    private TextView tx_status;

    private View mView;

    public Task_image_ViewHolder(View itemView) {
        super(itemView);
//        ButterKnife.bind(this,itemView);
        mView = itemView;
        icon = (QMUIRadiusImageView) itemView.findViewById(R.id.image_task_icon);
        tx_title = (TextView) itemView.findViewById(R.id.image_task_title);
        tx_subtitle = (TextView) itemView.findViewById(R.id.image_task_subTitle);
        tx_money = (TextView) itemView.findViewById(R.id.image_task_money);
        tx_count = (TextView) itemView.findViewById(R.id.image_task_count);
        img_sub = (ImageView) itemView.findViewById(R.id.image_task_subIcon);
        status_layout = (RelativeLayout) itemView.findViewById(R.id.image_status_layout);
        tx_status = (TextView) itemView.findViewById(R.id.image_status);
    }

    @SuppressLint("SetTextI18n")
    @Override
    public void bindViewData(Object data) {
        Task_image_Bean bean = (Task_image_Bean) data;
        if (bean.getIconUrl() == null || TextUtils.isEmpty(bean.getIconUrl())) {
            //当不返回icon时 使用默认类型图片
            icon.setImageDrawable(bean.getmContext().getResources().getDrawable(bean.getIconResid()));
        } else {
            Glide.with(mView).load(bean.getIconUrl()).placeholder(bean.getmContext().getResources().getDrawable(R.drawable.placeholder)).into(icon);
        }
        img_sub.setImageResource(bean.getIconResid());
        tx_title.setText(bean.getTitle());
        tx_subtitle.setText(bean.getSubTitle());
        tx_money.setText("+" + DecimalFormatHelper.getFloat2(CJCore.getRealMoney_float(bean.getMoney())) + "元");
        tx_count.setText("剩余:" + bean.getHaveCount());

        tx_status.setText(bean.getModel().getStatus());
        status_layout.setBackgroundColor(bean.getStatusBackground());
    }
}
